/**
 * @File Name: protocol_com.h
 * @brief  
 *  协议相关通用定义
 * @Author : LiWanglin email:lwl510ll@163.com
 * @Version : 1.0
 * @Creat Date : 2023-07-11
 * 
 * @copyright Copyright (c) 2023 LiWanglin
 */

#ifndef _PROTOCOL_PROTOCOL_COM_H_
#define _PROTOCOL_PROTOCOL_COM_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "common.h"

#define PROTOCOL_HEADER1 (0xFE)
#define PROTOCOL_HEADER2 (0xFD)
#define CRC_NUM1         (0xFF)


typedef struct _protocol_data
{
    cm_uint8 header[2];
    cm_uint16 serial_num;
    cm_uint16 cmd_num;
    cm_uint8 *data;
    cm_uint8 checksum[2];
    cm_uint16 data_len;
} protocol_data;

typedef enum _parser_status {
    PARSER_GET_HEADER = 0x00,
    PARSER_GET_LEN,
    PARSER_GET_SERIAL_NUM,
    PARSER_GET_CMD_NUM,
    PARSER_GET_DATA,
    PARSER_GET_CHECKSUM,
    PARSER_FINISH_FAILED,
    PARSER_FINISH_SUCCESS
}parser_status;

#ifdef __cplusplus
}
#endif

#endif  /* _PROTOCOL_PROTOCOL_COM_H_ */